public class Calculate {
    int a;
    int m;
    double y;
    double figure1;
    double figure2;

    Calculate(int a, int m, double y){
        this.a = a;
        this.m = m;
        this.y = y;
    }

    double principal(){
        figure1 = (double) (m + 1) * a * (y/12) / 2;
        return figure1;
    }
    double interest(){
        figure2 = (m * a *(y/12)) * (Math.pow(1 + (y/12),m)) / ((Math.pow(1 + (y/12),m) - 1) )- a;
        return figure2;
    }
//    void print(){
//        System.out.println("等额本金还款法，需要支付的总利息为：" + figure1);
//        System.out.println("等额本息还款法，需要支付的总利息为：" + figure2);
//    }
}
